package structuralPattern.singletonPattern;
// 懒汉模式、线程安全、防止序列化和反射破解
public class LazyPattern {
    private static LazyPattern instance;
    private LazyPattern(){
        if (null != instance ){
            throw new RuntimeException("不允许反射");
        }
    }
    public static synchronized LazyPattern getInstance(){
        if( null == instance){
            instance =  new LazyPattern();
        }
        return instance;
    }
    public LazyPattern readResolve() throws RuntimeException{
        return instance;
    }
}
